<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>登陆</title>
  <link rel="stylesheet" href="/static/v6/login/css/login.css">


  <style>
    *{
      margin: 0;
      padding: 0;
    }
  </style>
</head>
<body>
<div id="wrap" style=" background: url('/static/v6/login/img/login.png') no-repeat;">
  <div class="content">
    <div class="login">
      <div class="left" style=" background: url('/static/v6/login/img/left.png') no-repeat;" >
        <div class="logo" >
          园区管理<br />

        </div>
      </div>
      <div class="right">
        <div class="tip">
          <h3>园区管理系统后台</h3>
          <h4>WELCOME  LOGIN！</h4>
        </div>
        <ul class="inp-wrap">
          <li><input type="text" id="user_name" placeholder="请输入用户名"></li>
          <li><input type="password" id="user_pass"  placeholder="请输入密码"></li>
          <li class="code"><input id="img_code" type="text" placeholder="请输入验证码">
            <img src="" id="codeImg" onclick="image()" width="100" height="40" ></li>
          <li >
            <button  id="submit_bt" >登&nbsp;&nbsp;陆</button>
          </li>
        </ul>

        <div class="Copyright">COPYRIGHT © 2019 广告服务</div>
      </div>

    </div>

  </div>

</body>
<script type="text/javascript" src="/static/v6/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        image();
    });
    var math_code = Math.random();
    function image() {

        $("#codeImg").attr('src', "/v6/img/imgcode?math_code=" + math_code);
    }
    $("#submit_bt").click(function(){

        if($("#user_name").val()==null||$("#user_name").val()==""){
            alert("账户不能为空");
            return;
        }

        if($("#user_pass").val()==null||$("#user_pass").val()==""){
            alert("密码不能为空");
            return;
        }
        if($("#img_code").val()==null||$("#img_code").val()==""){
            alert("验证码不能为空");
            return;
        }
        var data = "campus_account="+$("#user_name").val()+"&campus_psd="+$("#user_pass").val()+"&img_code="+$("#img_code").val() + "&session_code=" + math_code ;
        $.ajax({
            type:'post',
            url:'/v6/logins',
            dataType : 'json',
            data: data,
            contentType: "application/x-www-form-urlencoded; charset=utf-8",
            success:function(data){
                if (data.mark=="0") {
                    sessionStorage.setItem("token", data.obj.token);
                    window.location.href="/v6/index?token="  + data.obj.token;
                } else {
                    alert(data.tip);
                }
            },
            error: function(textStatus) {
                alert(textStatus);
            }

        });
    });
</script>
</html>